/**
 * 
 */
package sopia.sg;

import sopia.conn.DBAdapter;
import sopia.conn.SQLQuery;
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;

/**
 * @author tatsu@gmail.com
 *
 */
public class G006Activity extends Activity {
	private static String[] PROJECTION = new String[] {
		 SQLQuery.KEY_NAME_ACCOUNT, SQLQuery.KEY_AMOUNT_ACCOUNT
    };

	/**
	 * 
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.g006_layout);
		DBAdapter db = new DBAdapter(this);
		db.open();
		init(db);
	
	}

	private void init(DBAdapter db) {
		ListView lstAcc = (ListView) findViewById(R.id.listAccount);
		Cursor cur = db.getAllAccount();
		
		SimpleCursorAdapter adapter2 = new SimpleCursorAdapter(this,
		    android.R.layout.simple_list_item_1, // Use a template
		                                          // that displays a
		                                          // text view
		    cur, new String[] {SQLQuery.KEY_NAME_ACCOUNT,SQLQuery.KEY_AMOUNT_ACCOUNT},
		    new int[] {android.R.id.text1,android.R.id.text2}); // The "text1" view defined in
		                                     // the XML template
		                                         
		adapter2.setDropDownViewResource(android.R.layout.simple_list_item_1);
		lstAcc.setAdapter(adapter2);
	}

}
